package com.platform.dao;

import com.platform.entity.UserEntity;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;

/**
 * 会员Dao
 *
 * @author lipengjun
 * @email 939961241@qq.com
 * @date 2017-08-16 15:02:28
 */
public interface UserDao extends BaseDao<UserEntity> {
    String getUserList(@Param("rootId") Integer rootId);

    String getUserChildListByLevel(@Param("rootId") Integer rootId, @Param("levelId") Integer levelId);

    @Update("update nideshop_user set account = account + #{freezeAccount}" +
            " where id = #{userId}")
    int unFreezeAccount(@Param("userId") Long userId, @Param("freezeAccount") BigDecimal freezeAccount);

    @Update("update nideshop_user set account = account + #{commission}" +
            " where id = #{userId}")
    int addCommission(@Param("userId") Long userId, @Param("commission") BigDecimal commission);

    @Update("update nideshop_user set account = account - #{account}" +
            " where id = #{userId} where account >= #{account}")
    int decreaseAccount(@Param("userId") Long userId, @Param("account") BigDecimal account);
}
